package com.sca4cloud.sca.microservice.start;

import java.lang.reflect.Method;

import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

@Order(Integer.MAX_VALUE - 1)
@Component
@Slf4j
public class BundleInit implements CommandLineRunner {

	@Override
	public void run(String... args) throws Exception {
		Class clz = null;
		try {
			clz = Class.forName("com.ylink.bdf.base.util.BundleUtil");
			log.info("ide 1.0 class [com.ylink.bdf.base.util.BundleUtil] initializer");
		} catch (Exception e) {
			clz = Class.forName("com.ylink.ide.trade.runtime.utils.BundleUtil");
			log.info("ide 2.0 class [com.ylink.ide.trade.runtime.utils.BundleUtil]  initializer");
		}
		if (clz != null) {
			Method m1 = clz.getMethod("setClassLoader", ClassLoader.class);
			m1.invoke(null, this.getClass().getClassLoader());
		}

	}

}
